<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    //5、小明家里有三个人，爸爸和妈妈，小明是男的，今年18岁，
    // 兴趣爱好是打篮球和读书，爸爸是软件程序员，妈妈是UI设计师，
    //小明家在深圳南山有一套100平方的房子，户型是三房一厅，
    //今年小明家刚买了一辆特斯拉Model3.
    //使用 **对象字面量**、**new Object** 、**构造函数** 三种方式创建以上对象




    console.log("-------------------1---对象字面量---------------------------")
    //小明
    let xiaoming = {
        year: 18,
        xingbie: "男",
        love: "打篮球和读书",
    }
    console.log(xiaoming);

    //爸
    let ba = {
        job: "软件程序员",
    }
    console.log(ba);

    //妈
    let ma = {
        job: "UI设计师",
    }
    console.log(ma);

    //房子
    let house = {
        dezhi: "深圳南山",
        daxiao: "100平方",
        huxing: "三房一厅",
    }
    console.log(house);

    //车
    let che = {
        leixing: "特斯拉Model3",
    }
    console.log(che);



    console.log("-------------------2---new Object--------------------------")

    //小明
    let xiaoming1 = new Object()
    xiaoming1.year = 18;
    xiaoming1.xingbie = "男";
    xiaoming1.love = "打篮球和读书";

    console.log(xiaoming1);


    //爸
    let ba1 = new Object()
    ba1.job = "软件程序员";

    console.log(ba1);


    //妈
    let ma1 = new Object()
    ma1.job = "UI设计师";

    console.log(ma1);


    //房子
    let house1 = new Object()
    house1.dezhi = "深圳南山";
    house1.daxiao = "100平方";
    house1.huxing = "三室一厅";

    console.log(house1);

    //车
    let che1 =new Object()
    che1.leixing = "特斯拉Model3";

    console.log(che1);
    console.log("-----------------3---构造函数------------------------")


    //小明
    function Person(year, xingbie, love) {
        this.year = year;
        this.xingbie = xingbie;
        this.love = love;
    }

    let xiaoming2 = new Person(18, "男", "打篮球和读书");

    console.log(xiaoming2);


    //爸
    function Per(job) {
        this.job = job;
    }

    let ba2 = new Per("软件程序员");
    console.log(typeof ba2);
    console.log(ba2);


    //妈
    function Pson(job) {
        this.job = job;
    }

    let ma2 = new Pson("UI设计师");
    console.log(typeof ma2);
    console.log(ma2);


    //房子
    function Peon(dezhi,daxiao,huxing){
        this.dezhi =dezhi;
        this.daxiao = daxiao;
        this.huxing = huxing;

    }

    let house2 = new Peon("深圳南山" ,"100平方","三房一厅");
    console.log(typeof house2);
    console.log(house2);


    //车
   function Pon(leixing){
        this.dleixing = leixing; 
    }
 
    let che2 = new Pon ("特斯拉Model3");
    console.log(typeof che2);
    console.log(che2);
</script>

</html>